package com.eureka.eurekaserviceinvoker.controller;

import com.eureka.eurekaserviceinvoker.client.PersonClient;
import com.eureka.eurekaserviceinvoker.client.TestClient;
import com.eureka.eurekaserviceinvoker.entity.Person;
import com.google.common.collect.ImmutableMap;
import com.netflix.loadbalancer.ZoneAwareLoadBalancer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.client.ServiceInstance;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.cloud.client.loadbalancer.LoadBalancerClient;
import org.springframework.cloud.netflix.ribbon.SpringClientFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import javax.servlet.http.HttpServletRequest;

/**
 *
 * Created by earl on 2018/4/17.
 */
@Configuration
@RestController
@RequestMapping("/invoker")
public class InvokerController {

    @Autowired
    private PersonClient personClient;

    @Autowired
    private TestClient testClient;

    @GetMapping("/hello")
    public String hello( ){
        return  personClient.hello()  ;
    }


    @GetMapping("/person/{id}")
    public Person person(@PathVariable Long id){
        Person p = new Person();
        p.setId(1L);
        return  personClient.person(id,p)  ;
    }

    //测试使用自定义注解
    @GetMapping("/hello2")
    public String hello2( ){
        return  testClient.hello2()  ;
    }




}
